<template>
    <el-input v-model="formContent" placeholder="内容" />
    <el-button type="primary" @click="addContent">添加内容</el-button>

    <el-table :data="logData">
    <el-table-column prop="id" label="Id" width="180" />
    <el-table-column prop="content" label="内容" width="180" />
    <el-table-column prop="optUid" label="创作者ID" />
  </el-table>
</template>

<script setup>

import { ref, onMounted } from 'vue'
import httpRequest from '@/request/index'

const formContent = ref('')

const logData = ref([])

function addContent() {
    httpRequest({
        url: '/log/add',
        method: 'post',
        data: {
            content: formContent.value
        }
    }).then((res) => {
        if (res.code === 0) {
            getList();
        }
    })
}

function getList() {
    httpRequest({
        url: '/log',
        method: 'get',
    }).then((res) => {
        if (res.code === 0) {
            logData.value = res.data
        }
    })
}

onMounted(() => {
    getList()
})
</script>